// 合规所有属性
export const allProperty = [
	{ key: 'isRiskMeasures', label: '是否有风控措施：预警、止损、最大回撤及其他风控措施等', componentType: 'radio', componentText: '是否', show: '' },

	{ key: 'investLeverRate', label: '投资杠杆率上限（总资产/净资产）%', componentType: 'input', componentText: '', show: '' },

	{ key: 'earlyWarnLine', label: '有无预警线', componentType: 'radio', componentText: '有无', show: '' },

	{ key: 'earlyWarnNetWorth', label: '预警线对应的资产管理计划净值', componentType: 'input', componentText: '', show: 'riskInfo.earlyWarnLine === "0"' },

	{ key: 'stopLossLine', label: '有无止损线', componentType: 'radio', componentText: '有无', show: '' },

	{ key: 'stopLossNetWorth', label: '止损线对应的资产管理计划净值', componentType: 'input', componentText: '', show: "riskInfo.stopLossLine === '0'" },

	{ key: 'maxRetreat', label: '有无回撤预警线', componentType: 'radio', componentText: '有无', show: '' },

	{ key: 'otherRiskStep', label: '有无其他风控措施', componentType: 'radio', componentText: '有无', show: '' },

	{ key: 'otherRiskExpression', label: '其他风控措施-合同表述', componentType: 'textarea', componentText: '', show: "riskInfo.otherRiskStep === '0'" },

	{ key: 'managerIsInvestment', label: '管理人是否投入资金', componentType: 'radio', componentText: '有无', show: "baseInfo.planType === '2'" },

	{ key: 'managerInvestmentAmount', label: '管理人投入资金参与金额', componentType: 'input', componentText: '', show: "baseInfo.planType === '2'&&riskInfo.managerIsInvestment === '0'" },

	{ key: 'managerInvestmentRatio', label: '理人投入资金参与比例', componentType: 'input', componentText: '', show: "baseInfo.planType === '2'&&riskInfo.managerIsInvestment === '0'" },

	{ key: 'managerIsPartake', label: '管理人附属机构自有资金是否参与', componentType: 'radio', componentText: '有无', show: "baseInfo.planType === '2'" },

	{ key: 'managerPartakeAmount', label: '管理人及其附属机构自有资金参与金额（万元）', componentType: 'input', componentText: '', show: "baseInfo.planType === '2'&&riskInfo.managerIsPartake === '0'" },

	{ key: 'managerPartakeRatio', label: '管理人及其附属机构自有资金参与比例（%）', componentType: 'input', componentText: '', show: "baseInfo.planType === '2'&&riskInfo.managerIsPartake === '0'" },

	{ key: 'isCheckCompliance', label: '合规是否复核', componentType: 'radio', componentText: '是否', show: '' }
]

export function strExpression(str, data) {
	let isShow = false
	if (!str.trim()) {
		isShow = true
	} else {
		const msg = str.replace(/ /g, '') // 去掉表达式所有空格，避免split切割出现报错
		const list = msg.split('&&') // 这里只判断并且（&&）的情况
		const conditionList = []
		list.forEach(item => {
			const parenKey = item.split('.')[0]
			let childKey = ''
			if (item.split('.')[1].includes('===')) { // 判断严格相等于
				childKey = item.split('.')[1].split('===')[0]
			} else if (item.split('.')[1].includes('!==')) { // 判断严格不等于
				childKey = item.split('.')[1].split('!==')[0]
			} else if (item.split('.')[1].includes('!=')) { // 判断不等于
				childKey = item.split('.')[1].split('!=')[0]
			} else if (item.split('.')[1].includes('==')) { // 判断等于
				childKey = item.split('.')[1].split('==')[0]
			}
			const childValue = item.split('===')[1]
			const obj = {
				parenKey, // 表达式父对象
				childKey, // 表达式子属性
				childValue // 表达式子值
			}
			conditionList.push(obj)
		})
		conditionList.forEach(item => {
			if (data[item.parenKey][item.childKey] === item.childValue) {
				item.isShow = true
			} else {
				item.isShow = false
			}
		})
		// 这里只判断并且（&&）的情况
		isShow = !conditionList.some(item => !item.isShow)
	}
	return isShow
}
